package com.mqb.n4;

import com.mqb.n2.util.Sleeper;
import lombok.extern.slf4j.Slf4j;

/**
 * @author mqb
 * @date 2021/4/18 17:41
 */
@Slf4j(topic = "c.TestBlocks")
public class TestBlocks {
    public static void main(String[] args) {
        Number n1 = new Number();
        Number n2 = new Number();
        new Thread(() -> n1.a(), "t1").start();
        new Thread(() -> n2.b(), "t2").start();
    }
}

@Slf4j(topic = "c.Number")
class Number {
    public static synchronized void a() {
        Sleeper.sleep(3);
        log.debug("1");
    }

    public static synchronized void b() {
        log.debug("2");
    }
}
